#include<iostream>
using namespace std;
typedef long long LL;
LL n;
int main()
{
	cin >> n;
	/*int t = n & 1;
	n >>= 1;
	int ans = t == 1 ? 1 : 0;
	int ma = ans;*/
	//00000000011101
	//cout << "t=" << t << endl;
	//cout << "n=" << n << endl;
	int ans = 0;
	int ma = 0;
	for (int i = 0; i < 31; i++) {
		if (n & 1) {
			//if (t == 1) {
			//	ans++;
			//	//cout << "ans=" << ans << endl;
			//}
			//else {
			//	ans = 1;
			//	t = 1;
			//}
			//ma = max(ma, ans);
			ans++;
			ma = max(ans, ma);
		}
		else {
			ans = 0;
		}
		n >>= 1;
	}
	cout << ma << endl;
	return 0;
}